<template>
  <div>
    <FilterTable
      ref="tablePartDetail"
      height="auto"
      :columns="columnsPartDetail"
      columnsRef="partDetailModelTable"
      :isSelectColumn="false"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.columns = columns)"
    />
    <div class="dialogBottmView">
      <el-button size="small" type="primary" @click="closePage">取消</el-button>
    </div>
  </div>
</template>

<script>
import { queryRoRepairPartByTag } from '@/api/repair/repairAssign/repairAssign';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'partDetailModel',
  mixins: [dictionary],
  props: ['roNo'],
  data() {
    this.BaseTable = null;
    return {
      columnsPartDetail: this.createTableColumnsPartDetail()
    };
  },
  mounted() {
    this.BaseTable = this.$refs.tablePartDetail.$refs.pageTable;
    this.getPartDetail();
  },
  methods: {
    createTableColumnsPartDetail() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '仓库',
          dataIndex: 'STORAGE_NAME',
          sorter: true,
          filter: true,
          width: 110,
          filterType: 'input'
        },
        {
          title: '主要配件',
          dataIndex: 'IS_MAIN_PART',
          sorter: true,
          filter: true,
          width: 110,
          filterType: 'input',
          render: props => {
            return <span>{this.createDictText(props.row.IS_MAIN_PART, '1004')}</span>;
          }
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          width: 110,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true,
          width: 110,
          filterType: 'input'
        },
        {
          title: '配件数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '计量单位名称',
          dataIndex: 'UNIT_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件销售金额',
          dataIndex: 'PART_SALES_AMOUNT',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件成本单价',
          dataIndex: 'PART_COST_PRICE',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
        },
        {
          title: '配件成本金额',
          dataIndex: 'PART_COST_AMOUNT',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    async getPartDetail() {
      let res = await queryRoRepairPartByTag({ roNo: this.roNo[0].RO_NO });
      console.log(res.data, '集合');
      this.BaseTable.EXECUTE_INSERT(res.data.rows);
    },
    closePage() {
      this.$emit('close');
    }
  }
};
</script>
